﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Negocio;
using Dominio;

namespace Presentacion
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        string _paswword = string.Empty;

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            //aqui se recupera el password y se accede al sistema.
            int _return = 0;
            if (_paswword!="")
            {
                _return = new Persona_Log().Data_Persona_Autentications(_paswword);
                if (_return != -1)
                {
                    this.Hide();
                    //validamos si el usuario tiene mas de un perfil asignado.
                    if (Convert.ToInt32(_return) == 0)
                    {
                        FrmSistemas _sistemas = new FrmSistemas();
                        _sistemas.ShowDialog(this);
                    }
                    else
                    {
                        FrmMesas _mesas = new FrmMesas();
                        if (Convert.ToInt32(_return) == 3)
                        {
                            _mesas.sistema = 1;
                        }
                        else
                        {
                            _mesas.sistema = 2;
                        }
                       
                        _mesas.ShowDialog(this);
                    }
                    _paswword = "";
                    this.Show();
                }
                else
                {
                    MessageBox.Show("Codigo ingreso es incorrecto", "GMS Restaurant", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _paswword = "";
                }
            }
            else
            {
                MessageBox.Show("Ingrese un codigo", "GMS Restaurant", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _paswword = "";
            }
            
        }

        private void btn1_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "1";
        }

        private void btn2_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "2";
        }

        private void btn3_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "3";
        }

        private void btn4_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "4";
        }

        private void btn5_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "5";
        }

        private void btn6_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "6";
        }

        private void btn7_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "7";
        }

        private void btn8_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "8";
        }

        private void btn9_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "9";
        }

        private void btn0_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + "0";
        }

        private void btnPunto_Click(object sender, EventArgs e)
        {
            _paswword = _paswword + ".";
        }

        private void btnBorrar_Click(object sender, EventArgs e)
        {
            _paswword = "";
        }
    }
}
